package bsts.view.user;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JPanel;

import bsts.application.BSTSApplication;

public class MainWindow extends JFrame {

	private static final long serialVersionUID = 1L;

	private BSTSApplication manager;
	private MainPanel mainPanel;
	private JPanel pnlMain;

	private WindowListener windowListener = new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			manager.logout();
		}
	};

	public MainWindow(BSTSApplication manager) {
		super("Billing System for Telephone Services");
		this.manager = manager;

		mainPanel = new MainPanel(manager);

		pnlMain = new JPanel();
		pnlMain.setLayout(new GridLayout(1, 1));
		pnlMain.add(mainPanel);

		this.setLayout(new BorderLayout());
		this.add(pnlMain, BorderLayout.CENTER);
		this.addWindowListener(windowListener);
	}

}
